package com.xiaoxie.report.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoxie.common.constant.Constants;
import com.xiaoxie.report.domain.QueryCondition;
import com.xiaoxie.report.mapper.QueryConditionMapper;
import com.xiaoxie.report.mapper.ReportConfigMapper;
import com.xiaoxie.report.mapper.ReportDataMapper;
import com.xiaoxie.report.service.ReportDataService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportDataServiceImpl implements ReportDataService {

    @Resource
    private ReportDataMapper reportDataMapper;
    @Resource
    private QueryConditionMapper queryConditionMapper;


    @Override
    public PageInfo<Map<String, Object>> queryData(String sql, Map<String,String> params, Integer reportId, Integer pageNum) {
        PageHelper.startPage(pageNum, Constants.PAGE_SIZE);
        List<QueryCondition> conditions = queryConditionMapper.getConditionByReportId(reportId);
        List<Map<String, Object>> maps = reportDataMapper.queryData(sql,params,conditions);
        return new PageInfo<>(maps);
    }


}
